g=(x * x for x in range(10))

print(g)

#generator func
def fib(max):
    n,a,b=0,0,1
    while n < max:
        print(b)
        a,b = b,a+b
        n=n+1
    return 'done'

fib(10)

def fibg(max):
    n,a,b=0,0,1
    while n < max:
        yield b
        a,b = b,a+b
        n=n+1
    return 'done'

f=fibg(10)
print(f)
print(next(f))

#for loop get return value
while True:
    try:
        x=next(f)
        print('f:',x)
    except StopIteration as e:
        print('Generator return value:',e.value)
        break

